/**
 * @author QinGuan
 * @date:2016-1-25 下午02:29:18
 * @version :3.0
 *
 */
package com.ctvit.struts.action;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.ServletActionContext;
import com.ctvit.framework.struts2.ActionSupport;
import com.ctvit.framework.web.context.ContextHolder;
import com.ctvit.sms.platform.domain.Contentlog;
import com.ctvit.sms.platform.service.ContentLogService;

@SuppressWarnings("serial")
public class ContentLogAction extends ActionSupport {
	private List<Map<String, ?>> contentJson = null;// 保存结果集
	private Map<String, Object> jsonMap = null;  //保存结果集
	private ContentLogService contentService = ContextHolder
			.getBean(ContentLogService.class);// service处理类
	private HttpServletRequest request = ServletActionContext.getRequest();// 获取请求内容的上下文

	/**
	 * 
	 * @ps:获取源系统的id
	 * @return
	 */
	public String getSourceId() {
		contentJson = contentService.getSourceId();
		return "SourseId";
	}

	/**
	 * 
	 * @ps:获取目标系统的id
	 * @return
	 */
	public String getTargetId() {
		contentJson = contentService.getTargetId();
		return "TargetId";
	}

	/**
	 * 
	 * @ps:获取服务器名称
	 * @return
	 */
	public String getTargetService() {
		contentJson = contentService.getTargetService();
		return "TargetSer";
	}

	/**
	 * 
	 * @ps:获取查询结果的列表
	 * @return
	 */
	public String getContentList() {
		Map<String, String> map = new HashMap<String, String>();
		String rows = request.getParameter("rows");// 每页显示条数
		String CurPages = request.getParameter("page");// 当前页号码
		int row = Integer.parseInt(rows);
		int CurPage = Integer.parseInt(CurPages);
		int pageSize = row == 0 ? 0 : row; // 页面显示条数
		int firstRow = (CurPage - 1) * pageSize;// 需要查询的起始行号
		map.put("zSourceSysId", request.getParameter("zSourceSysId"));
		map.put("zTargetSysId", request.getParameter("zTargetSysId"));
		map.put("zTargetService", request.getParameter("zTargetService"));
		map.put("zState", request.getParameter("zStatus"));
		map.put("beginDate", request.getParameter("beginDate"));
		map.put("endDate", request.getParameter("endDate"));
		map.put("firstRow", String.valueOf(firstRow));
		map.put("pageSize", String.valueOf(pageSize));
		List<Contentlog> list = contentService.getContentList(map);
		jsonMap = new HashMap<String, Object>();
		jsonMap.put("total", list.size());
		jsonMap.put("rows", list);
		return "ContentList";
	}
	
	public List<Map<String, ?>> getContentJson() {
		return contentJson;
	}

	public void setContentJson(List<Map<String, ?>> contentJson) {
		this.contentJson = contentJson;
	}

	public Map<String, Object> getJsonMap() {
		return jsonMap;
	}

	public void setJsonMap(Map<String, Object> jsonMap) {
		this.jsonMap = jsonMap;
	}
}
